package thinkingInJava.others;

import static thinkingInJava.YTool.YPrint.println;

import java.util.ArrayList;
import java.util.List;

public class Foreach {
	public static void t_String(){
		List<String> list = new ArrayList<String>();
		list.add("1");
		list.add("2");
		list.add("3");
		for(String s: list)
			s = s+"1";
		println(list);
	}
	public static void t_A(){
		class A{
			private int i;
			A(int i){
				this.i = i;
			}
			void set(int i){
				this.i = i;
			}
			@Override
			public String toString() {
				return ""+i;
			}
		}
		List<A> aList = new ArrayList<A>();
		aList.add(new A(1));
		aList.add(new A(2));
		aList.add(new A(3));
		for(A a: aList)
			a.set(0);
		println(aList);
	}
	public static void t_null() {
	    List<String> list = null;
	    for(String s: list) {
	        println(s);
	    }
	}
	public static void main(String[] args){
//		t_String();
//		t_A();
	    t_null();
	}
}
// output:
//[1, 2, 3]
//[0, 0, 0]
// https://my.oschina.net/u/860267/blog/775931